#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/stat.h>

char* crnt;
enum MError {NOERROR = 0, NONUMBER = 1, NOBKT = 2, NOEOF = 3};
enum MError MERROR;

int GetT();
int GetN();
int GetP();
int GetE();
int GetG(char* str);
int GetGError();
char* FileToArray(char* FileName);

int main()
{
    char FileName[100];
    scanf("%s", FileName);
    char* expression = FileToArray(FileName);
    puts(expression);
    int val = GetG(expression);
    if (!GetGError()) printf("%d\n", val);
    else printf("Error: %d", GetGError());
}

int GetN()
{
    int val = 0;
    if (! ('0' <= *crnt && *crnt <= '9') ) MERROR = NONUMBER;
    else
    {
        while ('0' <= *crnt && *crnt <= '9') val = val*10 + *crnt++ - '0';
    }
    return val;
}

int GetP()
{
    if (MERROR) return 0;
    if (*crnt == '(')
    {
        crnt++;
        int val = GetE();
        if (MERROR) return 0;
        if (*crnt == ')')
        {
            crnt++;
            return val;
        }
        else
        {
            MERROR = NOBKT;
            return 0;
        }
    }
    else return GetN();
}

int GetE()
{
    if (MERROR) return 0;
    int val = GetT();
    if (MERROR) return 0;
    while (*crnt == '+')
    {
        crnt++;
        val += GetT();
        if (MERROR) return 0;
    }
    return val;
}

int GetT()
{
    if (MERROR) return 0;
    int val = GetP();
    if (MERROR) return 0;
    while (*crnt == '*')
    {
        crnt++;
        val *= GetP();
        if (MERROR) return 0;
    }
    return val;
}

int GetG(char* str)
{
    MERROR = NOERROR;
    crnt = str;
    int val = GetE();
    if (MERROR) return 0;
    if (*crnt == '\0') return val;
    else
    {
        MERROR = NOEOF;
        return 0;
    }
}

int GetGError()
{
    return MERROR;
}

char* FileToArray(char* FileName)
{
    assert(FileName);
    FILE* File = fopen(FileName, "r");

    assert(File);

    struct stat buf;

    fstat(fileno(File), &buf);

    long long unsigned Length = (long long unsigned) buf.st_size;

    assert(Length);

    char* result = (char*) calloc(Length + 1, sizeof(*result));
    assert(result);

    for (int i = 0; i < Length - 1; i++)
    {
        fscanf(File, "%c", &result[i]);
    }
    fclose(File);
    File = NULL;
    return result;
}
